home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / art&graf.ix / art-0014 / extra / somb.c < prev    next >
Text File  |  1997-04-16  |  2KB  |  109 lines

  1. extern float sin(),cos(),exp();
  2. int contrl[12], intin[256], ptsin[256], intout[256], ptsout[256];
  3. float x, y, dfy, py, f;
  4. float pi,SIN_THETA,COS_THETA;
  5. int width,xcount,ycount;
  6. int top[1000],bottom[1000];
  7. int handle,height,i,dummy;
  8. int oldx,oldy;
  9. int NUM_LINES;
  10. int pxy[4];
  11.  
  12. #define TRUE 1
  13. #define FALSE 0
  14.  
  15. float func()
  16. {
  17. return(cos((x*x+y*y)*5.)*exp(-x*x-y*y));
  18. }
  19.  
  20. float scalex()
  21. {
  22. float temp;
  23. temp=width/2.;
  24. return((xcount-temp)/width*pi);
  25. }
  26.  
  27. float scaley()
  28. {
  29. float temp;
  30. temp=NUM_LINES/2.;
  31. return((temp-ycount)/NUM_LINES*pi);
  32. }
  33.  
  34. unscaley()
  35. {
  36. return((dfy+2.)/4.*height);
  37. }
  38.  
  39.  
  40.  
  41. main()
  42. {
  43. register visible, dy;
  44.  
  45. /* The following is the setup to use the VDI and AES */
  46.  
  47. /* Set the system up to do GEM calls*/
  48.  
  49.   appl_init();
  50.  
  51. /* Get the handle of the desktop */
  52.  
  53. handle=graf_handle(&width,&height,&dummy,&dummy);
  54.  
  55.   /* Open the workstation. */
  56.  
  57.   for (i=1; i<10; ++i) intin[i] = i;
  58.   intin[10] = 2;
  59.  
  60.   v_opnvwk(intin, &handle, intout);
  61.  
  62.   graf_mouse(256,pxy);
  63.  
  64.     width=intout[0];
  65.     height=intout[1];
  66.     vswr_mode(handle,2);
  67.     v_clrwk(handle);
  68.     oldx=0;
  69.     oldy=0;
  70.     NUM_LINES=64;
  71.     SIN_THETA=.5;
  72.     COS_THETA=0.866;
  73.     pi=3.14159;
  74.  
  75.     for (ycount=0; ycount<NUM_LINES; ++ycount) {
  76.         y=scaley();
  77.         py=y*SIN_THETA;
  78.         for (xcount=0; xcount<(width+1); ++xcount) {
  79.             x=scalex();
  80.             f=func();
  81.             dfy=py-f*COS_THETA;
  82.             dy=unscale();
  83.             if (xcount==0)
  84.                 visible=FALSE;
  85.             else if (ycount==0) {
  86.                 top[xcount]=dy;
  87.                 bottom[xcount]=dy;
  88.                 visible=TRUE; }
  89.             else {    visible=TRUE;
  90.                 if (top[xcount]<dy)
  91.                     top[xcount]=dy;
  92.                 else if (bottom[xcount]>dy)
  93.                     bottom[xcount]=dy;
  94.                 else
  95.                     visible=FALSE; }
  96.             if (visible==TRUE) {
  97.                 vsl_color(handle,1);
  98.                 pxy[0]=oldx;
  99.                 pxy[1]=oldy;
  100.                 pxy[2]=xcount;
  101.                 pxy[3]=dy;
  102.                 v_pline(handle,2,pxy); }
  103.             oldx=xcount;
  104.             oldy=dy;
  105.         }
  106.     }
  107. evnt_keybd();
  108. }
  109. ə